package com.hxkcloud.patient.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.hxkcloud.patient.R;
import com.hxkcloud.patient.beans.StopDrugsRecordBean;

import java.util.List;

/**
 * Created by MingNuo on 2017/7/15.
 */

public class StopDrugsAdapter extends BaseAdapter {

    private List<StopDrugsRecordBean> datas;
    private Context mContext;
    private LayoutInflater mInflater;

    public StopDrugsAdapter(List<StopDrugsRecordBean> datas, Context mContext) {
        this.datas = datas;
        this.mContext = mContext;
        mInflater = LayoutInflater.from(mContext);
    }

    @Override
    public int getCount() {
        return datas.size();
    }

    @Override
    public Object getItem(int position) {
        return null;
    }

    @Override
    public long getItemId(int position) {
        return 0;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {

        ViewHolder holder = null;
        if(convertView == null)
        {
            holder = new ViewHolder();
            convertView = mInflater.inflate(R.layout.item_stop_drugs, null);

            holder.tv_date = (TextView) convertView.findViewById(R.id.tv_date);
            holder.tv_name = (TextView) convertView.findViewById(R.id.tv_name);
            holder.tv_content = (TextView) convertView.findViewById(R.id.tv_content);
            holder.view_line = (View) convertView.findViewById(R.id.view_line);

            convertView.setTag(holder);
        }else
        {
            holder = (ViewHolder) convertView.getTag();
        }

        if(position == 0)
        {
            holder.view_line.setVisibility(View.GONE);
        }else
        {
            holder.view_line.setVisibility(View.VISIBLE);
        }



        holder.tv_date.setText(datas.get(position).getCreateTime());
        holder.tv_name.setText(datas.get(position).getMedicineName());
        holder.tv_content.setText(datas.get(position).getContent());

        return convertView;
    }
    /*
   * Holder
   */
     class ViewHolder{
        View view_line;
        TextView tv_date,tv_name,tv_content;
    }
}
